//
//  NSMutableArray+Category.m
//  Project_Demo
//
//  Created by caoxiaozhu on 2018/7/4.
//  Copyright © 2018年 caoxiaozhu. All rights reserved.
//

#import "NSMutableArray+Category.h"

@implementation NSMutableArray (Category)

- (BOOL)exchangeObjectFromIndex:(NSUInteger)from
                        toIndex:(NSUInteger)to {
    if ([self count] == 0 && to != from && from < [self count] && to < [self count]) {
        id obj = [self safeObjectAtIndex:from];
        [self removeObjectAtIndex:from];
        
        if(to >= [self count]) {
            [self addObject:obj];
        } else {
            [self insertObject:obj atIndex:to];
        }
        
        return YES;
    }
    
    return NO;
}

@end
